package com.mikao.controller.homePage;

import com.mikao.dto.bo.HomePageForm;
import com.mikao.dto.bo.ReqDataTableDto;
import com.mikao.dto.vo.HomePageDto;
import com.mikao.dto.vo.RspDataTableDto;
import com.mikao.service.HomePageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 轮播图
 * @author KennyDavid
 */
@RestController
@RequestMapping("/homePage")
public class HomePageController{


    private HomePageService homePageService;

    public HomePageController(HomePageService homePageService) {
        this.homePageService = homePageService;
    }

    @GetMapping("/getImageList")
    public RspDataTableDto<HomePageDto> getImageList(ReqDataTableDto dataTableDTO,
                                                     @RequestParam(value = "type",required = false) String type){
       return homePageService.findHomePageList(dataTableDTO,type);

    }

    @PostMapping("/saveImage")
    public void saveHomePage(HomePageForm homePageForm){
        homePageService.saveHomePage(homePageForm);
    }

    @PostMapping("/updateImage/{id}")
    public void updateImage(@RequestParam("imageUpload") MultipartFile imageUpload, @PathVariable("id") Long id){
        homePageService.updateImage(imageUpload,id);
    }

    @PostMapping("/modifyStatus/{id}")
    public void modifyStatus( @PathVariable("id") Long id){
        homePageService.modifyStatus(id);
    }
}
